#include <msp430x20x3.h>

unsigned int TX_data;
unsigned int TX_bit_count;

void main(void)
{
 WDTCTL = WDTPW + WDTHOLD;

 BCSCTL1 = CALBC1_1MHZ;
 DCOCTL = CALDCO_1MHZ;

 P1SEL |= 0x20; //(1)
 P1DIR |= 0x20; //(1)

 TX_bit_count = 10;

 TX_data = 'r';      //(2-a)
 TX_data |= 0x0100;  //(2-b)
 TX_data <<= 1;      //(2-c)
 TX_data &= ~0x0001; //(2-d)

 CCR0 = 10000;           //(3-a)
 CCR1 = 0;               //(3-b)
 CCTL0 = OUTMOD0 + CCIE; //(3-c)

 TACTL = TASSEL_2 + MC_2;//(4)
 _BIS_SR(LPM0_bits + GIE);
 while(1);
}

#pragma vector=TIMERA0_VECTOR
__interrupt void timerA_0(void)
{
 CCR0 += 208;

 if(TX_bit_count == 0){
  CCTL0 &= ~CCIE;        //(6)
  _BIC_SR_IRQ(LPM0_bits);
 } else{
  if(TX_data & 0x01) CCTL0 &= ~OUTMOD2; //(5-a)
  else CCTL0 |= OUTMOD2;                //(5-b)

  TX_data >>= 1;
  TX_bit_count--;
 }
}


